import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import "../common"
import "../../communication"

DefaultSubUI{

    width: 800
    height:600



    Text{
        id:title
        text:"请选择关卡"
        anchors{
            top:parent.top
            topMargin: 4
        }


        color:"grey"
        font{
            pixelSize: 20
            bold: true
        }
    }

    Rectangle{
        id:levelSelector
        anchors{
            top:title.bottom
            topMargin: 40
            left:parent.left
            right:parent.right
        }

        height:200

        ListView{
            id:levelList
            clip: true
            spacing: 10
            orientation:ListView.Horizontal
            anchors{
                fill:parent
                topMargin:10
                leftMargin:10
                rightMargin:10
                bottomMargin:10
            }

            delegate: LevelButton{
                text:modelData.name
                icon{
                    source: modelData.iconImage
                }
            }

            model:EventBus.defaultLevels.children

        }

        color:Qt.rgba(0,0,0,0.2)

    }

    Rectangle{
        anchors{
            top:levelSelector.bottom
            topMargin: 20
            right:parent.right
            bottom:parent.bottom
        }

        width: 300

        color:Qt.rgba(0,0,0,0.2)

        Text {
            anchors{
                fill:parent
                topMargin: 20
                leftMargin: 20
                rightMargin: 20
                bottomMargin: 20
            }
            wrapMode: Text.Wrap
            text:levelList.currentIndex === -1?"":levelList.model[levelList.currentIndex].comment

        }

    }


}
